<!--
 * @Author: Haochen
 * @Date: 2021-12-13 10:53:33
 * @LastEditTime: 2021-12-25 17:48:32
 * @FilePath: \recipes-admin-system\src\components\common\SideMenu.vue
-->
<template>
  <el-menu
    :default-active="$route.path"
    active-text-color="#7799fa"
    class="el-menu-vertical-demo"
    @open="handleOpen"
    @close="handleClose"
    :collapse="isCollapse"
    :router="true"
  >
    <el-menu-item v-for="item in menu" :key="item._id" :index="item.path">
      <i :class="item.icon"></i>
      <span slot="title">{{ item.title }}</span>
    </el-menu-item>
  </el-menu>
</template>

<script>
export default {
  data() {
    return {
      menu: [
        {
          _id: '1',
          title: '首页',
          icon: 'el-icon-s-home',
          path: '/home',
        },

        {
          _id: '2',
          title: '用户管理',
          icon: 'el-icon-user-solid',
          path: '/home/admins',
        },
        {
          _id: '3',
          title: '轮播图管理',
          icon: 'el-icon-picture',
          path: '/home/swiper',
        },

        {
          _id: '4',
          title: '菜谱管理',
          icon: 'el-icon-s-order',
          path: '/home/recipes',
        },

        {
          _id: '5',
          title: '会员管理',
          icon: 'el-icon-s-custom',
          path: '/home/members',
        },
        {
          _id: '6',
          title: '套餐管理',
          icon: 'el-icon-s-shop',
          path: '/home/meals',
        },
      ],
      isCollapse: true,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style scoped>
.el-menu {
  width: 65px;
  border: none;
  overflow: hidden;
}
</style>
